<template>
  <transition name="slide-fade" mode="out-in" appear>
    <!-- 过渡动画-标识区分是不同的渲染组件，绑定其 key = $route.name -->
    <keep-alive :include="keepAliveComponents" :max="10">
      <router-view :key="$route.name"></router-view>
    </keep-alive>
  </transition>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'RouteTransition',
  data() {
    return {}
  },
  computed: {
    ...mapGetters(['keepAliveComponents'])
  }
}
</script>

<style lang="less" scoped>
.slide-fade-enter-active {
  transition: all 0.5s ease;
}
.slide-fade-leave-active {
  transition: all 0.5s ease;
}
.slide-fade-enter {
  transform: translateX(-30px);
  opacity: 0;
}
.slide-fade-leave-to {
  transform: translateX(30px);
  opacity: 0;
}
</style>
